package domain.entities;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import static javax.persistence.GenerationType.IDENTITY;

/**
 * Created with IntelliJ IDEA.
 * User: nico
 * Date: 22/08/12
 * Time: 10:32
 * To change this template use File | Settings | File Templates.
 */
@Entity
@Table(name = "doctor_degree", catalog = "bms")
public class DoctorDegree implements Comparable, Serializable{

    private Integer id;
    private String descripcion;
    private List<Involucrado> involucrados = new ArrayList<Involucrado>();

    public DoctorDegree(Integer id,
                        String descripcion) {
        this.id = id;
        this.descripcion = descripcion;
    }

    public DoctorDegree(String descripcion) {

        this.descripcion = descripcion;
    }

    public DoctorDegree() {
    }


    @Id
    @GeneratedValue(strategy = IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }
    @Column(name = "descripcion")
    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    @Override
    public int compareTo(Object o) {
        DoctorDegree otro = (DoctorDegree)o;
        return this.descripcion.compareTo(otro.descripcion);
    }

    @OneToMany(mappedBy = "degree")
    @LazyCollection(LazyCollectionOption.FALSE)
    public List<Involucrado> getInvolucrados() {
        return this.involucrados;
    }

    public void setInvolucrados(List<Involucrado> involucrados) {
        this.involucrados = involucrados;
    }
}